package com.adopapa.nezhacloud.common;

import java.io.Serializable;


public enum DataType {

	/**
	 * data:,<文本数据> data:text/plain,<文本数据> data:text/html,<HTML代码>
	 * data:text/html;base64,<base64编码的HTML代码> data:text/css,<CSS代码>
	 * data:text/css;base64,<base64编码的CSS代码> data:text/javascript,<Javascript代码>
	 * data:text/javascript;base64,<base64编码的Javascript代码>
	 * 编码的gif图片数据 编码的png图片数据
	 * 编码的jpeg图片数据
	 * 编码的icon图片数据
	 */

	NONE("data:,"), //
	TEXT_PLAIN("data:text/plain,"), //
	TEXT_HTML("data:text/html,"), //
	TEXT_HTML_BASE64("data:text/html;base64,"), //
	TEXT_CSS("data:text/css,"), //
	TEXT_CSS_BASE64("data:text/css;base64,"), //
	TEXT_JAVASCRIPT("data:text/javascript,"), //
	TEXT_JAVASCRIPT_BASE64("data:text/javascript;base64,"), //
	IMAGE_GIF_BASE64("data:image/gif;base64,"), //
	IMAGE_PNG_BASE64("data:image/png;base64,"), //
	IMAGE_JPEG_BASE64("data:image/jpeg;base64,"), //
	IMAGE_JPG_BASE64("data:image/jpg;base64,"), //
	IMAGE_XICON_BASE64("data:image/x-icon;base64,"),;

	private String value;

	private DataType(String value) {
		this.value = value;
	}

	public String getName() {
		return name();
	}

	public String getValue() {
		return value;
	}

	public static int prefixLength(String imageData) {
		if (imageData.indexOf(NONE.value) == 0) {
			return NONE.value.length();
		}
		if (imageData.indexOf(TEXT_PLAIN.value) == 0) {
			return TEXT_PLAIN.value.length();
		}
		if (imageData.indexOf(TEXT_HTML.value) == 0) {
			return TEXT_HTML.value.length();
		}
		if (imageData.indexOf(TEXT_HTML_BASE64.value) == 0) {
			return TEXT_HTML_BASE64.value.length();
		}
		if (imageData.indexOf(TEXT_CSS.value) == 0) {
			return TEXT_CSS.value.length();
		}
		if (imageData.indexOf(TEXT_CSS_BASE64.value) == 0) {
			return TEXT_CSS_BASE64.value.length();
		}
		if (imageData.indexOf(TEXT_JAVASCRIPT.value) == 0) {
			return TEXT_JAVASCRIPT.value.length();
		}
		if (imageData.indexOf(TEXT_JAVASCRIPT_BASE64.value) == 0) {
			return TEXT_JAVASCRIPT_BASE64.value.length();
		}
		if (imageData.indexOf(IMAGE_GIF_BASE64.value) == 0) {
			return IMAGE_GIF_BASE64.value.length();
		}
		if (imageData.indexOf(IMAGE_PNG_BASE64.value) == 0) {
			return IMAGE_PNG_BASE64.value.length();
		}
		if (imageData.indexOf(IMAGE_JPEG_BASE64.value) == 0) {
			return IMAGE_JPEG_BASE64.value.length();
		}
		if (imageData.indexOf(IMAGE_JPG_BASE64.value) == 0) {
			return IMAGE_JPG_BASE64.value.length();
		}
		if (imageData.indexOf(IMAGE_XICON_BASE64.value) == 0) {
			return IMAGE_XICON_BASE64.value.length();
		}

		return 0;

	}

	//"图片base64数据信息")
	public static class ImageData implements Serializable {
		private static final long serialVersionUID = -8339662492184692327L;

		private String base64Value;

		public String getBase64Value() {
			return base64Value;
		}

		public void setBase64Value(String base64Value) {
			this.base64Value = base64Value;
		}

	}
	
	
	public static void main(String[] args) {
		
		
		
		
	}

}
